<?php
include 'PHPMailer/class.phpmailer.php';
include 'PHPMailer/class.smtp.php';

//接收留言
$name = (isset($_POST['name'])) ? trim($_POST['name']) : '';
$mobile = (isset($_POST['mobile'])) ? trim($_POST['mobile']) : '';
$address = (isset($_POST['address'])) ? trim($_POST['address']) : '';


//发送邮件
$mail = new PHPMailer();
$mail->IsSMTP(); //使用SMTP方式发信
$mail->SMTPAuth = true; //SMTP是否需要验证(STMP服务器基本都需要验证)
$mail->CharSet = "UTF-8"; //语言编码

$mail->Host = "smtp.163.com";    // SMTP服务器地址
$mail->Username = "servicelsok";   // 发信邮箱登录用户名
$mail->Password = "753951";   //发信邮箱登录密码

$mail->From = "servicelsok@163.com";   //发件人地址 即完整的SMTP发信邮箱
$mail->FromName = "旧书出售咨询";    //发件人名称 设置一个醒目的名称即可 目的是邮件不被忽略

$mail->AddAddress("help@lsok.net");  //接收留言的管理员邮箱
$mail->WordWrap = 50;
$mail->IsHTML(true);

$mail->Subject = "旧书出售咨询";   //邮件标题

//定义邮件主体内容
$mail_content = "<ul>";
$mail_content .= "<li>旧书名称: " . $name . "</li>";
$mail_content .= "<li>联系电话: " . $mobile . "</li>";
$mail_content .= "<li>地址: " . $address . "</li>";
$mail_content .= "</ul>";

$mail->Body = $mail_content; //邮件主体内容
	  
$mail->Send(); //发送邮件

echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'; 
echo '<script>alert("留言已收到!");location.href="http://m.jiushuhuishouwang.com/";</script>';
?>